// TestCaseModel
// (c)2007 Mark Bulmahn. mBulmahn@web.de
// License: GPL 2.0
// Project: TestCaseGenerator. http://www.codeplex.com/TestCaseGenerator

using System;
using System.Collections.Generic;
using System.Text;

namespace TestCaseModel
{
    /// <summary>
    /// A List of expected results used in a test model
    /// </summary>
    public class ExpectedResults : List<ExpectedResult>
    {
        public delegate void ItemRemovedHandler(ExpectedResult removeItem);
        public event ItemRemovedHandler ItemRemoved;

        public bool Exists(string id)
        {
            foreach (ExpectedResult r in this)
            {
                if (r.Id == id)
                    return true;
            }
            return false;
        }

        public new bool Remove(ExpectedResult item)
        {
            bool res = base.Remove(item);
            if (ItemRemoved != null)
                ItemRemoved(item);
            return res;
        }

        public ExpectedResult GetById(string id)
        {
            foreach (ExpectedResult r in this)
                if (r.Id == id)
                    return r;
            return null;
        }

        public void ChangeId(string oldId, string newId)
        {
            foreach (ExpectedResult r in this)
            {
                if (r.Id == oldId)
                    r.Id = newId;
            }
        }
    }
}
